<%@ page import="com.dao.MessageDao" %>
<%@ page import="com.bean.Message" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: 24497
  Date: 2020/8/2 0002
  Time: 22:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>借阅成功</title>
</head>
<body>
<%
    String book_name = request.getParameter("book_name");
    int x = (int) request.getAttribute("sum");
    if (x != -1) {
        out.write("借阅《" + book_name + "》成功");

        String name = (String) session.getAttribute("name");
        Message message = new Message();

        message.setName(name);
        message.setBook_name(book_name);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        message.setDate(simpleDateFormat.format(new Date()));

        MessageDao messageDao = new MessageDao();
        messageDao.addMessage(message);
    } else {
        out.write("《" + book_name + "》" + "已被全部借阅");
    }
%>
<br><br>
<a href="${pageContext.request.contextPath}/returnBook.jsp">还书</a><br>
<a href="${pageContext.request.contextPath}/borrowBook.jsp">借书</a><br>
<a href="${pageContext.request.contextPath}/loginOut.jsp">注销</a><br><br>
<a href="${pageContext.request.contextPath}/getMessage.jsp">查看借阅情况</a>

</body>
</html>
